package cn.edu.cug.cs.gtl.oi.inventor.demo;

import com.openinventor.inventor.SbBox2i32;
import com.openinventor.inventor.SbVec3i32;
import com.openinventor.inventor.SoPreferences;
import com.openinventor.inventor.devices.SoBufferObject;
import com.openinventor.inventor.devices.SoCpuBufferObject;
import com.openinventor.ldm.readers.SoVolumeReader;
import com.openinventor.volumeviz.readers.SoVRVolFileReader;

import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

public class VoxFileReader {
    public static void main(String[] args) {
        String fileName = SoPreferences.getValue("OIVJHOME") + "/data/volumeviz/3DHEAD.VOL";

        SoVRVolFileReader reader = new SoVRVolFileReader();
        reader.setFilename(fileName);
        long []  r3 = reader.getMinMax();
        System.out.println(r3);
        SoVolumeReader.DataInfo r2 = reader.getDataChar();
        System.out.println(r2);
        SbVec3i32 r1= reader.getTileSize();
        System.out.println(r1);
        int r = reader.getNumSignificantBits();
        System.out.println(r);
        SoBufferObject buf = new SoCpuBufferObject();
        reader.getSubSlice(new SbBox2i32(1,1,2,2),1,buf);
        System.out.println(buf);
        ByteBuffer data = buf.map( SoBufferObject.AccessModes.READ_ONLY );
        data.rewind();
        System.out.println(data.get());
        buf.unmap();
    }
}
